package com.radon;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient  //将当前服务注册到eureka上
@EnableFeignClients //开启Feign
@EnableHystrix//开启Hystrix断路器
public class StuConsumptionApplication {

    public static void main(String[] args) {
        SpringApplication.run(StuConsumptionApplication.class, args);
    }

    //解决RestTemplate找不到问题：应该把restTemplate注册到springboot容器中
    @Bean
    @LoadBalanced //开启负载均衡功能，并且支持别名方式调用生产者(否则无法使用别名)
    RestTemplate restTemplage() {
        return new RestTemplate();
    }

}
